﻿/*===================================================
* CLR版本  : 4.0.30319.42000 
* 类名称   : ComponentFactory
* 文 件 名 : ComponentFactory 
* 类描述   :
* 创建人   : oream
* 创建时间 : 2018/2/11 19:27:58
* 修改人   : 
* 修改时间 :
* 版本： @version 1.0
=====================================================*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace Hotfix
{
  /// <summary>
  /// 组件工厂
  /// </summary>
  public static class ComponentFactory
  {
    /*
     1:加载游戏物体
     2:拿到游戏物体的Reference
     3:获游戏物体引用
     4:获取对应的热更新组件脚本
     5:完成AddComponent
       */

    public static T Create<T>(Entity entity) where T : Component
    {
      T disposer = Hotfix.ObjectPool.FetchObject<T>();
      disposer.Parent = entity;
      Hotfix.EventSystem.Awake(disposer);
      return disposer;
    }
    public static T Create<T, A>(Entity entity, A a) where T : Component
    {
      T disposer = Hotfix.ObjectPool.FetchObject<T>();
      disposer.Parent = entity;
      Hotfix.EventSystem.Awake(disposer, a);
      return disposer;
    }

    public static T Create<T, A, B>(Entity entity, A a, B b) where T : Component
    {
      T disposer = Hotfix.ObjectPool.FetchObject<T>();
      disposer.Parent = entity;
      Hotfix.EventSystem.Awake(disposer, a, b);
      return disposer;
    }
    public static T Create<T, A, B, C>(Entity entity, A a, B b, C c) where T : Component
    {
      T disposer = Hotfix.ObjectPool.FetchObject<T>();
      disposer.Parent = entity;
      Hotfix.EventSystem.Awake(disposer, a, b, c);
      return disposer;
    }


  }
}
